<template>
  <a-modal :maskClosable="false"
    :title='title'
    :width='1248'
    :visible='visible'
    :confirmLoading='confirmLoading'
    @ok='handleOk'
    @cancel='handleCancel'
    cancelText='关闭'>

    <a-spin :spinning='confirmLoading'>

      <a-tabs default-active-key='1'>
        <a-tab-pane key='1' tab='基本计划信息'>
          <a-form-model ref='form' v-bind='layout' :model='model' >
            <a-row>
              <a-col span='12'>
                <a-form-model-item label='开始日期' prop='startTime'>
                  <a-input   v-model='model.startTime' readOnly />
                </a-form-model-item>
              </a-col>
              <a-col span='12'>
                <a-form-model-item label='结束日期' prop='endTime'>
                  <a-input   v-model='model.endTime' />
                </a-form-model-item>
              </a-col>
            </a-row>
            <a-row>
              <a-col span='12'>
                <a-form-model-item label='完成执行次数(次/月)' required prop='execCount'>
                  <a-input placeholder='请输入完成执行次数(次/月)' v-model='model.execCount' style='width: 200px' readOnly />
                </a-form-model-item>
              </a-col>
              <a-col span='12'>

              </a-col>
            </a-row>

            <a-row>
              <a-col span='12'>
                <a-form-model-item label='执行人类型' required prop='execType'>
                  <a-radio-group v-model='model.execType' disabled='disabled'>
                    <a-radio value='0'>
                      社区
                    </a-radio>
                    <a-radio value='1'>
                      内部职工
                    </a-radio>
                  </a-radio-group>
                </a-form-model-item>
              </a-col>
              <a-col span='12'>
                <a-form-model-item label='执行人' required prop='eyName'>
                  <a-input placeholder='请输入执行人' v-model='model.eyName' readOnly />
                </a-form-model-item>
              </a-col>
            </a-row>
            <a-row justify='start'>
              <a-form-item label='计划走访事务' required prop='followUpContent' :label-col='{span: 3 }'
                           :wrapperCol='{span: 20 }'>
                <a-textarea v-model='model.followUpContent' style='height: 300px' readOnly></a-textarea>
              </a-form-item>
            </a-row>
          </a-form-model>
        </a-tab-pane>
        <a-tab-pane key='2' tab='服务对像' force-render>
          <a-row :gutter='18'  style="margin-top: 10px">
            <a-col :span='22'>
              <!-- 查询区域 -->
              <a-form layout='inline' class='j-inline-form'>
                <!-- 固定条件 -->
                <a-form-item label='长者姓名'>
                  <a-input placeholder='请输入长者姓名' v-model='queryParam.realName'></a-input>
                </a-form-item>
                <a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
                <a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
              </a-form>
              <a-table
                style="margin-top: 10px"
                size='middle'
                bordered
                rowKey='id'
                :columns='columns'
                :dataSource='dataSource'
                :pagination='ipagination'
                :loading='loading'
                @change='handleTableChange'>
              </a-table>
            </a-col>
          </a-row>
        </a-tab-pane>
      </a-tabs>

      <employee-dialog ref='employeeModal' @signOk='handleSignChoice'></employee-dialog>
    </a-spin>
  </a-modal>
</template>

<script>
import { httpAction, putAction, getAction, postAction } from '@api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { pushIfNotExist } from '@/utils/util'
import EmployeeDialog from '@views/his/dialog/EmployeeDialog'

export default {
  name: 'hHisInterviewPlanModal',
  mixins: [JeecgListMixin],
  components: {
    EmployeeDialog,
  },
  data() {
    return {
      title: '操作',
      visible: false,
      disableMixinCreated:true,
      model: {
        eyName: '',
        eyId: 0
      },
      layout: {
        labelCol: { span: 6 },
        wrapperCol: { span: 14 }
      },
      confirmLoading: false,
      url: {
        add: '/ch/interview/plan',
        edit: '/ch/interview/plan',
        list: '/ch/interview/detail/list'
      },
      queryParam: { source: '1' },
      columns: [
        {
          title: '长者姓名',
          align: 'center',
          dataIndex: 'patientName'
        },
        {
          title: '性别',
          align: 'center',
          dataIndex: 'patientSex'
        },
        {
          title: '年龄(岁)',
          align: 'center',
          dataIndex: 'patientAge'
        },
      ],
    }
  },

  created() {
    this.modelDefault = JSON.parse(JSON.stringify(this.model))
  },
  methods: {
    /** 删除已选择的 */

    view(record) {
      const that = this
      that.model = Object.assign({}, record)
      that.visible = true
      that.queryParam.planCode=record.planCode;
      that.loadData();
    },

    close() {
      this.$refs.form.clearValidate()
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      const that = this
      that.close()
    },
    handleCancel() {
      this.close()
    },
    onChange: function(e) {
      //社工
      if (e.target.value == '0') {
        this.$refs.butlerModal.show(false)
        this.$refs.butlerModal.disableSubmit = false
      } else {
        this.$refs.employeeModal.show()
        this.$refs.employeeModal.disableSubmit = false
      }
    },
    handleSignChoice(record) {
      if (this.model.execType == '1') {
        this.model.eyName = record.name
        this.model.eyId = record.id
      } else {
        this.model.eyName = record.name
        this.model.eyId = record.id
      }

    },
  }
}
</script>

<style scoped>

</style>